﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using com.fukefu.sql;

namespace com.fukefu.tools
{
    public class TitleExpandKeyword
    {
        List<string> list = new List<string>();
        Random random = new Random();
        public TitleExpandKeyword()
        {
            SqlServerOperate sql = new SqlServerOperate();
            SqlDataReader re = sql.Query("select * from [全局设置].[dbo].[_bt_附加词]");
            while (re.Read())
            {
                list.Add(re["word"].ToString());
            }
            re.Close();
            sql.Close();
        }
        //增加扩展词
        public string Get(string title)
        {
            if (string.IsNullOrEmpty(title))
            {
                return title;
            }
            //头部数据
            if (list.Count > 0)
            {
                if (random.Next(2) == 0)
                {
                    title = title + list[random.Next(list.Count)];
                }
                else
                {
                    title = list[random.Next(list.Count)] + title;
                }
            }
            return title;
        }
    }
}
